﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace JqueryNet.FormControl.FormWebControl
{
    public class JLabel : JWebControl
    {
        Label label;
        public JLabel(Label label)
            : base(label)
        {
            this.label = label;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "height":
                    Value = label.Height;
                    return;
                case "width":
                    Value = label.Width;
                    return;
                case "title":
                case "tooltip":
                    Value = label.ToolTip;
                    return;
                default:
                    base.Attr(key);
                    return;
            }

        }

        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            switch (key.ToLower())
            {
                case "height":
                    label.Height = b;
                    return;
                case "width":
                    label.Width = b;
                    return;
                case "title":
                case "tooltip":
                    label.ToolTip = value;
                    return;
                default:
                    base.Attr(key, value);
                    return;
            }

        }

        public override void Val()
        {
            Value = label.Text;
        }

        public override void Val(string value)
        {
            label.Text = value;
        }
    }
}
